// 声明装饰器修饰方法/属性
function method(
  target: any,//PersonIII 的原型
  propertyKey: string,//sayHello
  descriptor: PropertyDescriptor // PersonIII.prototype.sayHello 的描述符
) {
  console.log("method target=", target);
  console.log("method pk=" + propertyKey);
  console.log("method desc=" + JSON.stringify(descriptor) + "\n\n");

  // 让当前属性(say)不可编辑
  descriptor.writable = false;
}

function property(target: any, propertyKey: string) {
  console.log("property target", target);
  console.log("property propertyKey", propertyKey);
}

class PersonIII {
  @property
  name: string;

  constructor() {
    this.name = "huihui";
  }

  /* 直接拿到这个方法的对象描述符从而为所欲为 */
  @method
  sayHello() {
    console.log("基尼太美");
  }

  @method
  static run() {
    return "static method";
  }

}

const xkk = new PersonIII();

// 修改实例方法say
xkk.sayHello = function () {
  console.log("亭前一席话，胜坐十年牢");
};

xkk.sayHello();
